<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>父页面</h1>
    <iframe id="child" src="http://localhost:5500/1.html" height="200" frameborder="0"></iframe>
</body>
</html>
<script>
    let child = document.querySelector("#child");
    child.onload = function(){
        // child.contentWindow.fn(123)
        child.contentWindow.postMessage("p2c","http://localhost:5500/1.html")
    }
    console.log(a)
    var a = 0
    console.log(a)
    if(true){
        console.log(a)
        a =1
        console.log(a)
        function a(){

        }
        console.log(a)
        a=3
        console.log(a)
    }
    console.log(a)
</script>